package com.changer.common.service;

import java.io.File;
import java.util.List;

/**
 * @author Jiwei Guo
 *
 */
public interface OSSService {
	
	public String HTTP = "http://";
	
	public String HTTPS = "https://";
	
	/**
	 * 获取以https链接开头的下载地址，链接中带有签名，适用于私有bucket
	 * @param key
	 * @return
	 * @throws Exception
	 */
	public String getHttpsDownloadURLWithSignature(String key) throws Exception;
	
	/**
	 * 获取以http链接开头的下载地址，链接中带有签名，适用于私有bucket
	 * @param key
	 * @return
	 * @throws Exception
	 */
	public String getDownloadURLWithSignature(String key) throws Exception;
	
	/**
	 * 获取以http链接开头的下载地址，适用于公共bucket
	 * @param key
	 * @return
	 * @throws Exception
	 */
	public String getDownloadURL(String key) throws Exception;
	
	/**
	 * 获取以https链接开头的下载地址, 适用于公共bucket
	 * @param key
	 * @return
	 * @throws Exception
	 */
	public String getHttpsDownloadURL(String key) throws Exception;
	
	/**
	 * 上传文件,如果配置了压缩策略，同时会上传压缩图片
	 * @param file
	 * @return
	 * @throws Exception
	 */
	public String upload(File file) throws Exception;
	
	/**
	 * 仅上传指定文件的压缩文件
	 * @param file
	 * @return
	 * @throws Exception
	 */
	public String upload(File file, boolean justUploadCompressed) throws Exception;

	/**
	 * 上传文件
	 * @param file
	 * @return
	 * @throws Exception
	 */
	public String doUpload(File file,String prefixKey) throws Exception;

	/**
	 * 删除指定的key
	 * @param key
	 * @throws Exception
	 */
	public void deleteFile(String key) throws Exception;
	
	/**
	 * 批量删除指定的keys
	 * @param keys
	 * @throws Exception
	 */
	public void deleteFiles(List<String> keys) throws Exception;
	
	/**
	 * 下载指定的key文件
	 * @param key oss的key
	 * @param downloadPath 下载路劲
	 * @return
	 * @throws Exception
	 */
	public File download(String key, String downloadPath) throws Exception;
	
	/**
	 * 获取指定oss key的大小
	 * @param key
	 * @return
	 * @throws Exception
	 */
	public long size(String key) throws Exception;
	
	/**
	 * 指定的key是否存在
	 * @param key
	 * @return
	 * @throws Exception
	 */
	public boolean exist(String key) throws Exception;

	/**
	 * 获取指定前缀的key
	 * @param keyPrefix
	 * @return
	 * @throws Exception
	 */
	public List<String> getObjectsByPrefix(String keyPrefix) throws Exception;

}
